<template>
  <h1>循环指令</h1>
  <ul>
    <li v-for="i in 5">{{i}}</li>
  </ul>
  <ul>
    <li v-for="e in productArr">{{e.name}}</li>
  </ul>
  <table border="1px">
    <tr>
      <th>商品编号</th>
      <th>商品名称</th>
      <th>商品价格</th>

    </tr>
    <tr v-for="(e,i) in productArr">
      <td>{{i}}</td>
      <td>{{e.name}}</td>
      <td>{{e.price}}</td>
      <button @click="del(index)">删除</button>
    </tr>
  </table>
</template>
<script setup>
  import {ref} from "vue";
  const del = (index) => {
      if(confirm('确认删除吗')){
        productArr.value.splice(index,1);
      }
  };
  const productArr = ref([
      {name: 'apple', price: 5},
      {name: 'banana', price: 3},
      {name: 'orange', price: 2},
  ])
</script>

<style scoped>

</style>